﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security.Permissions;
using System.Web;
using System.Web.Configuration;

namespace Galaktika.BI.Silverlight.ClientApp.Web.Configuration
{
    [ConfigurationCollection(typeof(DataServiceCommand))]
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class DataServiceCommandCollection : ConfigurationElementCollection
    {
        public DataServiceCommandCollection()
        {
        }

        public void Add(DataServiceCommand dataServiceCommand)
        {
            this.BaseAdd(dataServiceCommand);
        }

        public void Clear()
        {
            base.BaseClear();
        }
        protected override ConfigurationElement CreateNewElement()
        {
            return new DataServiceCommand();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((DataServiceCommand)element).Id;
        }

        public void Remove(string key)
        {
            base.BaseRemove(key);
        }

        public void RemoveAt(int index)
        {
            base.BaseRemoveAt(index);
        }

        // Properties
        new public DataServiceCommand this[string cmdName]
        {
            get
            {
                return (DataServiceCommand)base.BaseGet(cmdName);
            }
        }

        public DataServiceCommand this[int index]
        {
            get
            {
                return (DataServiceCommand)base.BaseGet(index);
            }
            set
            {
                if (base.BaseGet(index) != null)
                {
                    base.BaseRemoveAt(index);
                }
                this.BaseAdd(index, value);
            }
        }
    }

}
